﻿using System.Collections.Generic;

namespace Inovout.Data.Domain
{
    public class DataObjectSet<TModel> : HashSet<TModel>, IDataObjectSet<TModel>
        , ISet<TModel>
    {
        public DataObjectSet() { }

        public DataObjectSet(IEnumerable<TModel> list)
        {
            this.AddAll(list);
        }
 
        public bool AddAll(IEnumerable<TModel> list)
        {
            bool changed = false;
            foreach (TModel o in list)
            {
                changed |= this.Add(o);
            }
            return changed;
        }
        public bool ContainsAll(ICollection<TModel> collection)
        {
            foreach (TModel o in collection)
            {
                if (!this.Contains(o))
                {
                    return false;
                }
            }
            return true;
        }
    }
}